package com.charles.seckillPlatform.controller;

import com.charles.seckillComponentCommon.domain.AjaxResult;
import com.charles.seckillPlatform.form.BankPayForm;
import com.charles.seckillPlatform.service.BankCheckService;
import com.charles.seckillPlatform.service.BankPayService;
import com.charles.seckillPlatform.vo.BankCardInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Charles-H
 * 
 * 本地支付
 */
@RestController
@RequestMapping("/bank")
public class BankPayController {

    @Autowired
    private BankCheckService bankCheckService;
    
    @Autowired
    private BankPayService bankPayService;

    @PostMapping("/pay")
    public AjaxResult pay(@RequestBody BankPayForm bankPayForm) {
        BankCardInfo bankCardInfo = bankCheckService.validBankInfo(bankPayForm.getPassword(), bankPayForm.getOrderId());
        bankPayService.payOrder(bankCardInfo, bankPayForm.getOrderId());
        return AjaxResult.success("订单支付成功!");
    }

}
